package com.beans;

import java.util.Collection;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.opensymphony.xwork2.util.CreateIfNull;

@Entity
@Table(name="POKER_USER")
public class User 
{
	@Id @GeneratedValue
	@Column(name="USR_ID")
	private int id;
	
	private Date created;
	
	@Column(name="USR_NAME")
	private String name;
	
	@Column(name="USR_LOCATION")
	private String location;
	
	@Column(name="USR_STACK")
	private Double stack;
	
	@OneToOne(cascade = CascadeType.ALL)
	private Place place;

	@OneToMany(mappedBy="user")
	private Collection<Round> rounds;
	
	@ManyToMany(cascade = CascadeType.ALL)
	@JoinTable(name = "POKER_TJ_CARD_USER", 
		joinColumns = { @JoinColumn(name = "USR_ID") }, 
		inverseJoinColumns = { @JoinColumn(name = "CRD_ID") }
	)
	private Collection<Card> cards;
	
	/*
	 * Getter / Setter for the main values
	 */
	
	public Collection<Round> getRounds() {
		return rounds;
	}
	
	public Collection<Card> getCards() {
		return cards;
	}

	public void setCards(Collection<Card> cards) {
		this.cards = cards;
	}

	public void setRounds(Collection<Round> rounds) {
		this.rounds = rounds;
	}

	public Place getPlace() {
		return place;
	}
	public void setPlace(Place place) {
		this.place = place;
	}
	
	public Double getStack() {
		return stack;
	}
	public void setStack(Double stack) {
		this.stack = stack;
	}
	
	public int getId() {
		return id;
	}
	public void setId(int identifiant) {
		this.id = identifiant;
	}

	public String getName(){
		return name;
	}

	public void setName(String newName){
		this.name = newName;
	}
	
	public String getLocation(){
		return location;
	}

	public void setLocation(String newLocation){
		this.location = newLocation;
	}
	
	public java.util.Date getCreated() {
		return created;
	}

	public void setCreated(java.util.Date dateInscription) {
		this.created = dateInscription;
	}
}